package com.pocket.mic.common.util;

import java.util.Date;

import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;

public class JsonDataValueProcessor implements JsonValueProcessor{
	
	public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd";  
    private String dateFormat;  
  
    public JsonDataValueProcessor(String dateFormat) {
		super();
		this.dateFormat = dateFormat;
	}

	public Object processArrayValue(Object value, JsonConfig jsonConfig) {  
        return process(value);  
    }  
  
    public Object processObjectValue(String key, Object value,  
        JsonConfig jsonConfig) {  
        return process(value);  
    }  
  
    private Object process(Object value) {  
        return TimeUtil.getDate((Date)value, dateFormat);  
    }  
}
